<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head lang="en">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="js/bootstrap.min.js"></script>
    <!-- 时刻表 -->
    <link rel="stylesheet" type="text/css" href="dist/bootstrap-clockpicker.min.css">
    <script type="text/javascript" src="dist/bootstrap-clockpicker.min.js"></script>
    <!-- 弹框 -->
    <script type="text/javascript" src="js/layer.js"></script>
    <link href="css/layer.css" type="text/css" rel="styleSheet" id="layermcss">
    <script type="text/javascript" src="js/pop.js"></script>
    <title>門店外賣設置</title>
</head>
<style>
    /*?提示信息样式*/
    .tooltip-inner {
        background-color: white;
        width: 250px;
        color: #6b6766;
        border: 1px solid gainsboro;
        text-align: left
    }

    .tooltip.bottom .tooltip-arrow {
        bottom: 0;
        left: 50%;
        border-width: 5px 5px 0;
        border-top-color: #00a189;
    }
</style>
<body>
<div class="record-main">
    <div class="main-title">門店外賣設置</div>
    <div class="record-content shop-set-content">
        <div class="shop-set-box">
            <h4>基本信息</h4>
            <div class="shop-list">
                <p style="margin-bottom: 20px;">店鋪名稱：名厨都汇（JW万豪酒店）</p>
                <div class="online-list-box"
                     style="height: 30px; margin-bottom: 20px;">
                    <p>
                        <span style="float: left;">門店狀態：</span>
                    </p>
                    <select onchange="Cmd(this)" onclick="mgsShow()" id="status"
                            onblur="mgsHide()" class="select-state form-control"
                            style="width: 120px; float: left; margin-top: -10px; outline: none">
                        <option value="0" selected name="">正常營業中</option>
                        <option value="1"  name="">暫停營業</option>
                    </select>
                    <div class="online-msg-box">
                        <div id="div1">
                            <div class="option-box">
                                <div class="option-left"><span id="option1" class="active">正常營業中</span></div>
                                <div class="option-right">當前餐廳處於設置的營業時內，用戶可正常點單</div>
                            </div>
                            <div class="option-box" style="margin: 10px 0">
                                <div class="option-left"><span id="option2">暫停營業</span></div>
                                <div class="option-right">適用於較長時間停止提供服務，不接受任何訂單，手動恢復營業後可正常接收訂單</div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--
                <div class="q-code-box">
                    <ul>
                        <li>门店二维码：</li>
                        <li><img src="/service/images/q-code-set.png" alt="" /></li>
                        <li style="vertical-align: bottom"><a href="">下载二维码</a></li>
                    </ul>
                </div>-->
            </div>
            <div class="online-set-box">
                <h4>营业设置</h4>
                <div class="online-set">
                    <div class="online-set-left">訂單時間：</div>
                    <div class="online-set-right">
                        <div class="online-box" id="online-box">
                            <div class="Modify"
                                 style="text-align: right; margin-bottom: 10px;">
                                <a href="#" style="cursor: hand;" onclick="onlineModif()">修改</a>
                            </div>
                            <table class="online-set-table table-bordered">
                                <tr>
                                    <td>週一</td>
                                    <td>週二</td>
                                    <td>週三</td>
                                    <td>週四</td>
                                    <td>週五</td>
                                    <td>週六</td>
                                    <td>週日</td>
                                    <td>開始時間</td>
                                    <td>結束時間</td>
                                </tr>
                                <tr class="Modif-checkbox">
                                    <td rowspan="100"><input type="checkbox" value="1"
                                                             disabled="disabled" name="weekDayNew" id="weekDay1"
                                                             checked /></td>
                                    <td rowspan="100"><input type="checkbox" value="2"
                                                             disabled="disabled" name="weekDayNew" id="weekDay2"
                                                             checked /></td>
                                    <td rowspan="100"><input type="checkbox" value="3"
                                                             disabled="disabled" name="weekDayNew" id="weekDay3"
                                                             checked /></td>
                                    <td rowspan="100"><input type="checkbox" value="4"
                                                             disabled="disabled" name="weekDayNew" id="weekDay4"
                                                             checked /></td>
                                    <td rowspan="100"><input type="checkbox" value="5"
                                                             disabled="disabled" name="weekDayNew" id="weekDay5"
                                                             checked /></td>
                                    <td rowspan="100"><input type="checkbox" value="6"
                                                             disabled="disabled" name="weekDayNew" id="weekDay6"
                                                             checked /></td>
                                    <td rowspan="100"><input type="checkbox" value="7"
                                                             disabled="disabled" name="weekDayNew" id="weekDay7"
                                                             checked /></td>
                                </tr>


                                <tr>
                                    <td><span>10:00</span></td>
                                    <td><span>16:00</span></td>
                                </tr>

                                <tr>
                                    <td><span>23:05</span></td>
                                    <td><span>23:20</span></td>
                                </tr>

                                <tr>
                                    <td><span>23:30</span></td>
                                    <td><span>23:50</span></td>
                                </tr>



                            </table>
                        </div>
                        <div class="online-modif" style="display: none;">
                            <div class="Modify"
                                 style="text-align: right; margin-bottom: 10px; height: 20px;">
                                <a href="#" style="cursor: hand;"> <em
                                        style="float: right; font-style: normal;"> <span
                                        onclick="onlineBack()">退出</span> <i
                                        style="margin: 0 5px; color: #00a189">/</i> <span
                                        style="color: #00a189" onclick="onlineSave('1')">保存</span></em></a>
                            </div>
                            <table
                                    class="online-set-table table-bordered online-modif-table">
                                <tr>
                                    <td>週一</td>
                                    <td>週二</td>
                                    <td>週三</td>
                                    <td>週四</td>
                                    <td>週五</td>
                                    <td>週六</td>
                                    <td>週日</td>
                                    <td>開始時間</td>
                                    <td>結束時間</td>
                                    <td>操作</td>
                                </tr>
                                <tbody id="addTr">
                                <tr align="center" class="save-checkbox">
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="1" name="weekDay"
                                            checked /></td>
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="2" name="weekDay"
                                            checked /></td>
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="3" name="weekDay"
                                            checked /></td>
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="4" name="weekDay"
                                            checked /></td>
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="5" name="weekDay"
                                            checked /></td>
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="6" name="weekDay"
                                            checked /></td>
                                    <td rowspan="100" style="vertical-align: top"><input
                                            type="checkbox" value="7" name="weekDay"
                                            checked /></td>
                                </tr>


                                <tr id="">
                                    <td style="padding: 10px 0" id="updateTime">
                                        <div class="input-group clockpicker"
                                             style="width: 130px; margin: 0 auto;">
                                            <input type="text" id="timeBegin" class="form-control"
                                                   style="border-radius: 5px; text-align: center"
                                                   value="10:00">
                                        </div> <input type="hidden" name="timeId" id="timeId"
                                                      value="201610031523158526548628"> <input type="hidden"
                                                                                               name="oldTimeBegin" id="oldTimeBegin"
                                                                                               value="10:00">
                                        <input type="hidden" name="oldTimeEnd" id="oldTimeEnd"
                                               value="16:00">
                                    </td>
                                    <td style="padding: 10px 0">
                                        <div class="input-group clockpicker"
                                             style="width: 130px; margin: 0 auto;">
                                            <input type="text" id="timeEnd" class="form-control"
                                                   style="border-radius: 5px; text-align: center"
                                                   value="16:00">
                                        </div>
                                    </td>
                                    <td onClick="getDel('201610031523158526548628')"><a href='#'
                                                                                        style='color: #00a189;'>删除</a></td>
                                </tr>

                                <tr id="">
                                    <td style="padding: 10px 0" id="updateTime">
                                        <div class="input-group clockpicker"
                                             style="width: 130px; margin: 0 auto;">
                                            <input type="text" id="timeBegin" class="form-control"
                                                   style="border-radius: 5px; text-align: center"
                                                   value="23:05">
                                        </div> <input type="hidden" name="timeId" id="timeId"
                                                      value="201611032255520032482675"> <input type="hidden"
                                                                                               name="oldTimeBegin" id="oldTimeBegin"
                                                                                               value="23:05">
                                        <input type="hidden" name="oldTimeEnd" id="oldTimeEnd"
                                               value="23:20">
                                    </td>
                                    <td style="padding: 10px 0">
                                        <div class="input-group clockpicker"
                                             style="width: 130px; margin: 0 auto;">
                                            <input type="text" id="timeEnd" class="form-control"
                                                   style="border-radius: 5px; text-align: center"
                                                   value="23:20">
                                        </div>
                                    </td>
                                    <td onClick="getDel('201611032255520032482675')"><a href='#'
                                                                                        style='color: #00a189;'>删除</a></td>
                                </tr>

                                <tr id="updateTime201611032310500689588879">
                                    <td style="padding: 10px 0" id="updateTime">
                                        <div class="input-group clockpicker"
                                             style="width: 130px; margin: 0 auto;">
                                            <input type="text" id="timeBegin" class="form-control"
                                                   style="border-radius: 5px; text-align: center"
                                                   value="23:30">
                                        </div> <input type="hidden" name="timeId" id="timeId"
                                                      value="201611032310500689588879"> <input type="hidden"
                                                                                               name="oldTimeBegin" id="oldTimeBegin"
                                                                                               value="23:30">
                                        <input type="hidden" name="oldTimeEnd" id="oldTimeEnd"
                                               value="23:50">
                                    </td>
                                    <td style="padding: 10px 0">
                                        <div class="input-group clockpicker"
                                             style="width: 130px; margin: 0 auto;">
                                            <input type="text" id="timeEnd" class="form-control"
                                                   style="border-radius: 5px; text-align: center"
                                                   value="23:50">
                                        </div>
                                    </td>
                                    <td onClick="getDel('201611032310500689588879')"><a href='#' style='color: #00a189;'>删除</a></td>
                                </tr>
                                </tbody>
                                <tr style="border: none">
                                    <td colspan="7" style="vertical-align: top"><input
                                            type="checkbox" style="display: none" checked /></td>
                                    <td colspan="3" style="padding: 10px 0">
                                        <div class="btn btn-default" id="getAtr"
                                             style="color: #00a189;">
                                            <i style="margin-right: 5px;">+</i>新增订餐时间
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="order-select">
                    <span>非營業時間下單：</span> <label class="checkbox-inline"> <input
                        type="radio"
                        checked
                        name="optionsRadiosinline" id="" value="1">&nbsp;&nbsp;支持
                </label> <label class="checkbox-inline"> <input type="radio"

                                                                name="optionsRadiosinline" id="" value="0">&nbsp;&nbsp;不支持
                </label>
                 <a  style="margin-left: 10px;"  rel="popover" data-placement="bottom"><img
                         src="images/question.png" style="width: 22px;" alt=""/></a>
                <div class="shopset-messages" style="width: 300px;border: 1px solid gainsboro;padding: 10px;display: none">如果支持“非營業時間”下單即爲預定，支持24小時內的預定。用戶在營業時間外下單時選擇配送時段直接讀取已設置好的訂單時段。</div>
               </div>
                <div class="order-select">
                    <span>商家公告：</span>
						<textarea class="form-control " placeholder="500字以内" maxlength="500" name="notice" id="notice" rows="5"
                                  style="width: 470px; height: 120px;">本店即日起进入外卖促销活动，凡在本店下单的顾客，均会得到一款限量版澳觅杯垫</textarea>
                </div>

                <div class="delivery-list-boxs">
                    <h4>配送信息</h4>
                    <div id="areaList">
                        <div class="delivery-list-box delivery-list1">
                            <div class="delivery-list delivery-list-title">
                                <div class="delivery-title" id="delivery-title1"
                                        >
                                    <span style="float: left">配送方案</span> <a href="#"
                                                                             style="cursor: hand;"> <em
                                        style="float: right; font-style: normal;"> <span
                                        style="color: #00a189" onclick="deliveryModif()">修改</span></em></a>
                                </div>
                                <div class="add-delivery-modified" id="add-delivery-modified">

                                    <div class="delivery-list-content">
                                        <dl>
                                            <dd>配送區域</dd>
                                            <dd>澳门半岛</dd>
                                        </dl>
                                        <dl>
                                            <dd>起送價</dd>
                                            <dd>30元</dd>
                                        </dl>
                                        <dl>
                                            <dd>配送價</dd>
                                            <dd>20元</dd>
                                        </dl>
                                    </div>

                                    <div class="delivery-list-content">
                                        <dl>
                                            <dd>配送區域</dd>
                                            <dd>氹仔</dd>
                                        </dl>
                                        <dl>
                                            <dd>起送價</dd>
                                            <dd>80元</dd>
                                        </dl>
                                        <dl>
                                            <dd>配送價</dd>
                                            <dd>40元</dd>
                                        </dl>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="delivery-list-box delivery-modif-box"
                         style="display: none;" >
                        <div class="delivery-title">
                            <span style="float: left">配送方案</span> <a href="#"
                                                                     style="cursor: hand;"><em class="modif-submit"
                                                                                               style="float: right; font-style: normal;"><span
                                onclick="deliveryBack()">退出</span> <i
                                style="margin: 0 5px; color: #00a189">/</i><span
                                style="color: #00a189" onclick="deliverySave()">保存</span></em></a>
                        </div>
                        <div class="delivery-list" id="delivery-list">

                            <div class="add-delivery-lists" id="areaListForm10001">
                                <div class="add-delivery-list" id="areaListForm">
                                    <ul>
                                        <li>
                                            <div class="form-group">
                                                <label class="delivery-label-l">配送區域</label>
                                                <div class="delivery-label-r">
                                                    <select class="form-control" id="selectUpdate"
                                                            name="selectUpdate" style="width: 200px;">

                                                        <option value="10001"
                                                                selected>澳门半岛</option>

                                                        <option value="10002"
                                                                >氹仔</option>

                                                        <option value="10003"
                                                                >路氹城</option>

                                                        <option value="10004"
                                                                >路环</option>

                                                        <option value="10005"
                                                                >澳门大学</option>

                                                    </select>
                                                </div>
                                            </div>
                                            <input type="hidden" name="oldAreaName" id="oldAreaName" value="澳门半岛">
                                            <input type="hidden" name="tareaId" id="tareaId" value="10001">
                                            <input type="hidden" name="olaSendBeginAmount" id="olaSendBeginAmount" value="30">
                                            <input type="hidden" name="oldAmountOfSend" id="oldAmountOfSend" value="20">
                                        </li>
                                        <li>
                                            <div class="form-group">
                                                <label>起送價&nbsp;&nbsp;&nbsp;&nbsp;</label>
                                                <input
                                                        type="number" style="text-align: center" min="0" onkeyup="replace(this);"
                                                        value="30" onblur="qPrice()"
                                                        id="sendBeginAmount" class="q-price" /> <span>元</span>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="form-group">
                                                <label class="">配送價&nbsp;&nbsp;&nbsp;&nbsp;</label> <input
                                                    type="number" style="text-align: center"
                                                    value="20" onblur="pPrice()" min="0" onkeyup="replace(this);"
                                                    id="amountOfSend" class="q-price p-price" /> <span>元</span>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="delivery-del">
                                    <a href="javascript:delAreaById('10001');"><span></span></a>
                                </div>
                            </div>

                            <div class="add-delivery-lists" id="areaListForm10002">
                                <div class="add-delivery-list" id="areaListForm">
                                    <ul>
                                        <li>
                                            <div class="form-group">
                                                <label class="delivery-label-l">配送區域</label>
                                                <div class="delivery-label-r">
                                                    <select class="form-control" id="selectUpdate"
                                                            name="selectUpdate" style="width: 200px;">

                                                        <option value="10001"
                                                                >澳门半岛</option>

                                                        <option value="10002"
                                                                selected>氹仔</option>

                                                        <option value="10003"
                                                                >路氹城</option>

                                                        <option value="10004"
                                                                >路环</option>

                                                        <option value="10005"
                                                                >澳门大学</option>

                                                    </select>
                                                </div>
                                            </div>
                                            <input type="hidden" name="oldAreaName" id="oldAreaName" value="氹仔">
                                            <input type="hidden" name="tareaId" id="tareaId" value="10002">
                                            <input type="hidden" name="olaSendBeginAmount" id="olaSendBeginAmount" value="80">
                                            <input type="hidden" name="oldAmountOfSend" id="oldAmountOfSend" value="40">
                                        </li>
                                        <li>
                                            <div class="form-group">
                                                <label>起送價&nbsp;&nbsp;&nbsp;&nbsp;</label>
                                                <input
                                                        type="number" style="text-align: center" min="0" onkeyup="replace(this);"
                                                        value="80" onblur="qPrice()"
                                                        id="sendBeginAmount" class="q-price" /> <span>元</span>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="form-group">
                                                <label class="">配送價&nbsp;&nbsp;&nbsp;&nbsp;</label> <input
                                                    type="number" style="text-align: center"
                                                    value="40" onblur="pPrice()" min="0" onkeyup="replace(this);"
                                                    id="amountOfSend" class="q-price p-price" /> <span>元</span>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="delivery-del">
                                    <a href="javascript:delAreaById('10002');"><span></span></a>
                                </div>
                            </div>

                            <div class="add-delivery-lists" style="display: none">
                                <div class="add-delivery-list" id="newArea">
                                    <ul>
                                        <li>
                                            <div class="form-group">
                                                <label class="delivery-label-l">配送區域</label>
                                                <div class="delivery-label-r">
                                                    <select class="form-control" id="selectAdd"
                                                            name="selectAdd" style="width: 200px;">

                                                        <option value="10001">澳门半岛</option>

                                                        <option value="10002">氹仔</option>

                                                        <option value="10003">路氹城</option>

                                                        <option value="10004">路环</option>

                                                        <option value="10005">澳门大学</option>

                                                    </select>
                                                </div>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="form-group">
                                                <label>起送價&nbsp;&nbsp;&nbsp;&nbsp;</label> <input
                                                    type="number" style="text-align: center" value="0" min="0"
                                                    onblur="qPrice()" id="sendBeginAmountNew" onkeyup="replace(this);" class="q-price" />
                                                <span>元</span>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="form-group">
                                                <label class="">配送價&nbsp;&nbsp;&nbsp;&nbsp;</label> <input
                                                    type="number" style="text-align: center" value="0" onkeyup="replace(this);" min="0"
                                                    onblur="pPrice()" id="amountOfSendNew"
                                                    class="q-price p-price" /> <span>元</span>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="delivery-del">
                                    <a href="javascript:void(0);" onclick="delNewArea(this);"><span></span></a>
                                </div>
                            </div>
                        </div>
                        <div class="btn btn-default" id="btn-default"
                             style="color: #00a189;" onclick="addDeliver(this)">
                            <span style="margin-right: 5px;">+</span>添加配送方案
                        </div>
                    </div>
                    <div class="text-center add-active-btn" style="border: none">
                        <a href="javascript:cancel();" class="btn btn-default">取消</a> <a
                            onclick="submitData('1');" class="btn btn-default"
                            style="background: #00a189; color: white; margin-left: 30px; border: none">保存</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 时间信息提示 -->
<div class="myModal" id="myModal-time1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-dialog-1" id="modal-dialog-mgs1" role="document" style="width: 500px; height: 370px;">
        <form action="">
            <div class="modal-content">
                <div class="modal-body del-modal">
                    系統提示
                    <h5 class="text-center">最多只能添加三个时间段。</h5>
                </div>
                <div class="modal-footer" style="border-top: 1px solid gainsboro; text-align: center;outline: none; color: #00a189;cursor: pointer" onclick="hideTime1()">
                   知道了
                </div>
            </div>
        </form>
    </div>
</div>
<!--开始时间不能大于结束时间-->
<div class="myModal" id="myModal-time2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-dialog-1" id="modal-dialog-msg2" role="document" style="width: 500px; height: 370px;">
        <form action="">
            <div class="modal-content">
                <div class="modal-body del-modal">
                    系統提示
                    <h5 class="text-center">開始時間不能大於結束時間</h5>
                </div>
                <div class="modal-footer" style="border-top: 1px solid gainsboro; text-align: center;outline: none; color: #00a189;cursor: pointer" onclick="hideTime2()">
                    知道了
                </div>
            </div>
        </form>
    </div>
</div>
<!--删除配送区域提示-->
<div class="myModal" id="myModal-time3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-dialog-1" id="modal-dialog-msg3" role="document" style="width: 500px; height: 370px;">
        <form action="">
            <div class="modal-content">
                <div class="modal-body del-modal">
                    系統提示
                    <h5 class="text-center">请设置保存至少一个配送方案</h5>
                </div>
                <div class="modal-footer" style="border-top: 1px solid gainsboro; text-align: center;outline: none; color: #00a189;cursor: pointer" onclick="hideTime3()">
                    知道了
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $(document).ready(function(){
       $('[rel=popover]').popover({
        html : true,
                content: function() {
            return $('.shopset-messages').html();
        }
    });
    });

    var openTimeTab=false;
    var openAreaTab=false;

    function replace(obj) {
        var inp_val = obj.value;
        if (!/[\d]/.test(inp_val)||inp_val < 0) {
            obj.value = inp_val.replace(/[\-\d]|[\-\d\.\d]/g, '');
        }

    }

    /*删除配送方案提示*/
    function deliveryDel() {
        parent.document.getElementById("myModal5").style.display = "block";
    }
    /*追加新增套餐时间*/
    $(function(){
        //最多只能添加3个时间段

        $("#getAtr").click(function(){
            var size=$("td[id='updateTime']").length;
            var sizeNewAdd=$("tr[id='newAdd']").length;
            if((size+sizeNewAdd)>=3){
//                pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">最多只能添加三个时间段。<p></div>');
                var scrollTop = parent.document.body.scrollTop;
                document.getElementById("modal-dialog-mgs1").style.top=scrollTop+220+'px';
                $("#myModal-time1").show();
                buttonObject.disable=true;
                return false;
            }
            $str='';
            $str+="<tr id='newAdd'>";
            $str+="<td style='padding: 10px 0;'>" +
                    '<div class="input-group clockpicker" style="width:130px;margin: 0 auto;">'+
                    '<input type="text" name="newTimeBegin" id="newTimeBegin" class="form-control" style="border-radius: 5px;text-align: center" value="00:00">'+
                    '</div></td>';
            $str+="<td style='padding: 10px 0;'>" +
                    '<div class="input-group clockpicker" style="width:130px;margin: 0 auto;">'+
                    '<input type="text" name="newTimeEnd" id="newTimeEnd" class="form-control" style="border-radius: 5px;text-align: center" value="00:00">'+
                    '</div></td>';
            $str+="<td onClick='del(this)'><a href='#' style='color: #00a189;'>删除</a></td>";
            $str+="</tr>";
            $("#addTr").append($str);
            //初始化调用时刻
            $('.clockpicker').clockpicker()
                    .find('input').change(function(){
                        console.log(this.value);
                    })
        });
    });
    function hideTime1(){
       $("#myModal-time1").hide();
    }
    function hideTime2(){
        $("#myModal-time2").hide();
    }
    function hideTime3(){
        $("#myModal-time3").hide();
    }
    var delArray=[];
    function getDel(id) {
        $("#updateTime"+id).remove();
        delArray.push(id);
    }

    function del(k){
        $(k).parent().remove();
    }
    //全局时刻调用
    $('.clockpicker').clockpicker().find('input').change(function() {
        console.log(this.value);
    })
    function addTime(obj) {
        var _this = $(obj);
        var append = $('tr.addTime-box').clone().show();
        _this.parent('tr').prepend(append);
    }
    //提示信息
    $(function() {
        $("[data-toggle='tooltip']").tooltip();
    });
    function qPrice() {
        var q_price = document.getElementById("sendBeginAmount").value;
        if (!(/(^[0-9]\d*$)/.test(q_price))) {
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请输入正整数。<p></div>');
            return false;
        }
    }
    function pPrice() {
        var q_price = document.getElementById("amountOfSend").value;
        if (!(/(^[0-9]\d*$)/.test(q_price))) {
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请输入正整数。<p></div>');
            return false;
        }
    }
    //门店状态显示
    function mgsShow() {
        $(".online-msg-box").css('display', 'block');
    }
    //门店状态隐藏
    function mgsHide() {
        $(".online-msg-box").css('display', 'none');
    }
    //門店營業狀態切換
    function Cmd(obj) {

        var storeStatus=$('#status').children('option:selected').val();
        var option1=$("#option1");
        var option2=$("#option2");
        if(storeStatus==0){
            option2.removeClass("active");
            option1.addClass("active");
        }
        if(storeStatus==1){
            option1.removeClass("active");
            option2.addClass("active");
        }
    }
    //訂單時間修改
    function onlineModif() {
        openTimeTab=true;
        $(".online-box").hide();
        $(".online-modif").show();

    }


    var timeArrayObject=[];
    var areaArrayObject=[];
    var weekDayStr='';

    //訂單時間保存
    function onlineSave(type) {

        weekDayStr='';
        timeArrayObject=[];

        var arrChk=$("input[name='weekDay']:checkbox:checked");
        $("input[name='weekDayNew']").removeAttr("checked");

        if(arrChk.length==0){
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请选择工作日。<p></div>');
            return ;
        }

        var weekDay='';
        for (var i=0;i<arrChk.length;i++){
            $('#weekDay'+arrChk[i].value).prop("checked",true);
            weekDay=weekDay+arrChk[i].value+',';
        }
        weekDayStr=weekDay;

        var size=$("td[id='updateTime']").length;
        var sizeNewAdd=$("tr[id='newAdd']").length;
        var data='',updateData='';

        for(var i=0;i<size;i++){
            var timebegin=$($("input[id='timeBegin']").eq(i)).val();
            var timeEnd=$($("input[id='timeEnd']").eq(i)).val();
            var timeId=$($("input[id='timeId']").eq(i)).val();
            data=data+"##"+timebegin+"*"+timeEnd+"*"+timeId;

            if(!checkEndTime(timebegin,timeEnd)){
//                pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">开始时间不能大于结束时间。<p></div>');
                var scrollTop = parent.document.body.scrollTop;
                document.getElementById("modal-dialog-msg2").style.top=scrollTop+220+'px';
                $("#myModal-time2").show();
                return ;
            }

            var oldtimebegin=$($("input[id='oldTimeBegin']").eq(i)).val();
            var oldtimeEnd=$($("input[id='oldTimeEnd']").eq(i)).val();
            if(!(timebegin == oldtimebegin&&timeEnd==oldtimeEnd)){
                updateData=updateData+"##"+timebegin+"*"+timeEnd+"*"+timeId;
                var timeObject=new Object();//需要更新的门店时间
                timeObject.timeBegin=timebegin;
                timeObject.timeEnd=timeEnd;
                timeObject.id=timeId;
                timeArrayObject.push(timeObject);
            }
        }
        var dataNew='';
        for(var i=0;i<sizeNewAdd;i++){
            var timebegin=$($("input[id='newTimeBegin']").eq(i)).val();
            var timeEnd=$($("input[id='newTimeEnd']").eq(i)).val();
            dataNew=dataNew+"##"+timebegin+"*"+timeEnd;

            if(!checkEndTime(timebegin,timeEnd)){
//                pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">开始时间不能大于结束时间。<p></div>');
                var scrollTop = parent.document.body.scrollTop;
                document.getElementById("modal-dialog-msg2").style.top=scrollTop+220+'px';
                $("#myModal-time2").show();
                return ;
            }

            var timeObject=new Object();//需要新增的门店时间
            timeObject.timeBegin=timebegin;
            timeObject.timeEnd=timeEnd;
            timeArrayObject.push(timeObject);
        }

        var time=data+dataNew;
        $.ajax({
            type: 'POST',
            async: false,
            url: "../takeOutStore/timeModal.shtml",
            data:'weekDay='+weekDay+'&time='+time,
            success: function(msg){
                $("#online-box").html('');
                $("#online-box").html(msg);
            }
        });

        openTimeTab=false;
        $(".online-modif").hide();
        $(".online-box").show();
    }
    function checkEndTime(startTime,endTime){
        var myDate = new Date();
        var dateStr=myDate.toLocaleDateString();
        var start=new Date(dateStr+' '+startTime );
        var end=new Date(dateStr+' '+endTime);
        if(end<start){
            return false;
        }
        return true;
    }
    //訂單時間退出
    function onlineBack() {
        openTimeTab=false;
        $(".online-modif").hide();
        $(".online-box").show();
    }
    //配送方案修改
    function deliveryModif() {
        openAreaTab=true;
        $(".delivery-modif-box").show();
        $(".delivery-list1").hide();
    }
    //配送方案保存
    function deliverySave(type) {

        areaArrayObject=[];
        var areaIdArray=[];

        var size=$("div[id='areaListForm']").length;//编辑的区域的数量
        var sizeNew=$("div[id='newArea']").length;//新增的区域的数量
        var data='';
        var updateData='';
        for(var i=0;i<size;i++){//编辑的数据
            var sendBeginAmount=$($("input[id='sendBeginAmount']").eq(i)).val();
            var amountOfSend=$($("input[id='amountOfSend']").eq(i)).val();
            var areaName=$($("select[name='selectUpdate']").eq(i)).find('option:selected').text();

            var areaId=$($("select[name='selectUpdate']").eq(i)).val();
            var oldAreaName=$($("input[id='oldAreaName']").eq(i)).val();
            var olaSendBeginAmount=$($("input[id='olaSendBeginAmount']").eq(i)).val();
            var oldAmountOfSend=$($("input[id='oldAmountOfSend']").eq(i)).val();
            var id=$($("input[id='tareaId']").eq(i)).val();

            if(jQuery.inArray(areaId,areaIdArray)>-1){
                pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">配送区域不能重复，请重新选择。<p></div>');
                return;
            }
            areaIdArray.push(areaId);
            if((oldAreaName!=areaName||olaSendBeginAmount!=sendBeginAmount||oldAmountOfSend!=amountOfSend)){
                updateData=updateData+"##"+sendBeginAmount+"*"+amountOfSend+"*"+areaId;

                var areaObject=new Object();
                areaObject.sendBeginAmount=sendBeginAmount;
                areaObject.amountOfSend=amountOfSend;
                areaObject.areaId=areaId;
                areaObject.id=id;
                areaArrayObject.push(areaObject);
            }

            data=data+"##"+sendBeginAmount+"*"+amountOfSend+"*"+areaName;
        }

        var dataNew='';
        var dataNewStr='';
        for(var i=0;i<sizeNew;i++){//新增的数据

            if(i==sizeNew-1){
                continue;
            }
            var sendBeginAmount=$($("input[id='sendBeginAmountNew']").eq(i)).val();
            var amountOfSend=$($("input[id='amountOfSendNew']").eq(i)).val();
            var areaName=$($("select[name='selectAdd']").eq(i)).find('option:selected').text();
            var areaId=$($("select[name='selectAdd']").eq(i)).val();
            dataNew=dataNew+"##"+sendBeginAmount+"*"+amountOfSend+"*"+areaName;
            //dataNewStr=dataNew+"##"+sendBeginAmount+"*"+amountOfSend+"*"+areaId;

            if(jQuery.inArray(areaId,areaIdArray)>-1){
                pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">配送区域不能重复，请重新选择。<p></div>');
                return;
            }

            areaIdArray.push(areaId);
            var areaObject=new Object();
            areaObject.sendBeginAmount=sendBeginAmount;
            areaObject.amountOfSend=amountOfSend;
            areaObject.areaId=areaId;
            areaArrayObject.push(areaObject);
        }
        if((data+dataNew).length==0){
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请先保存配送方案。<p></div>');
            return ;
        }
        $.ajax({
            type: 'POST',
            url: "../takeOutStore/areaModal.shtml",
            data:'areaData='+(data+dataNew),
            success: function(msg){
                $("#add-delivery-modified").html('');
                $("#add-delivery-modified").html(msg);
            }
        });
        openAreaTab=false;
        $(".delivery-list-box").css('display', 'block')
        $(".delivery-modif-box").css('display', 'none')
        $("#delivery-title1").css('display', 'block')
    }

    var delArea=[];
    function delAreaById(id){
        if(!areaSize()){
            return ;
        }
        $("#areaListForm"+id).remove();
        delArea.push(id);
    }


    function delNewArea(obj){
        if(!areaSize()){
            return ;
        }
        $(obj).closest('.add-delivery-lists').remove();
    }


    function areaSize(){
        var size=$("div[id='areaListForm']").length;//编辑的区域的数量
        var sizeNew=$("div[id='newArea']").length;//新增的区域的数量

        if((size+sizeNew)<=2){
//            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请设置保存至少一个配送方案.<p></div>');
            var scrollTop = parent.document.body.scrollTop;
            document.getElementById("modal-dialog-msg3").style.top=scrollTop+220+'px';
            $("#myModal-time3").show();
            return  false;
        }
        return true;
    }

    //配送方案退出
    function deliveryBack() {
        openAreaTab=false;
        $(".delivery-list-box").css('display', 'block')
        $(".delivery-modif-box").css('display', 'none')
        $(".delivery-title").css('display', 'block')
        $("#delivery-title1").css('display', 'block')
    }
    //添加配送方案
    function addDeliver(obj) {
        var _this = $(obj);
        var append = $('div.add-delivery-lists:hidden').clone().show();
        $('#delivery-list').prepend(append);
        $(".delivery-title").css('display', 'block')
        $("#delivery-title1").css('display', 'none')
    }


    function submitData(type){

        if(openTimeTab==true){
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请先保存营业时间.<p></div>');
            return;
        }

        if(openAreaTab==true){
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请先保存配送方案。<p></div>');
            return;
        }

        var arrChk=$("input[name='weekDayNew']:checkbox:checked");
        var storeStatus=$('#status').children('option:selected').val();

        var weekday='';
        for (var i=0;i<arrChk.length;i++){
            weekday=weekday+arrChk[i].value+',';
        }
        if(weekday.length==0){
            pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请选择营业工作日<p></div>');
            return;
        }
        if(type!=1){
            if(timeArrayObject.length==0){//默认时间
                var timeObject=new Object();//需要新增的门店时间
                timeObject.timeBegin='10:00';
                timeObject.timeEnd='22:00';
                timeArrayObject.push(timeObject);
            }
            if(areaArrayObject.length==0){
                pop.a('<div style="padding: 10px;"><span>提示信息</span><p style="margin: 20px;">请设置保存配送地址 。<p></div>');
                return;
            }
        }

        for (var i=0;i<delArea.length;i++){
            var areaObject=new Object();
            areaObject.id=delArea[i];
            areaArrayObject.push(areaObject);
        }

        for (var i=0;i<delArray.length;i++){
            var timeObject=new Object();
            timeObject.id=delArray[i];
            timeArrayObject.push(timeObject);
        }

        var submitObject=new Object();
        var optionsRadiosinline=$('input:radio[name="optionsRadiosinline"]:checked').val();
        var notice=$('#notice').val();

        submitObject.handClose=storeStatus;
        submitObject.acceptOnRest=optionsRadiosinline;
        submitObject.weekDay=weekday;
        submitObject.notice=notice;
        submitObject.areaList=areaArrayObject;
        submitObject.timeList=timeArrayObject;
        $.ajax({
            type: 'POST',
            async: true,
            dataType:"json",
            contentType:"application/json",
            url: "../takeOutStore/save.shtml",
            data:JSON.stringify(submitObject),
            beforeSend: function () {
                pop.loading("");
            },
            complete: function () {
                pop.close();
            },
            success: function(result){
                if(result==true){
                    com.toast('保存成功.');
                    setTimeout(function () {
                        window.location = '../takeOutStore/set.shtml';
                    },2000);
                }
            }
        });

        areaArrayObject=[];
        timeArrayObject=[];
        weekDayStr='';
        delArea=[];
        delArray=[];
    }

    function cancel(){
        areaArrayObject=[];
        timeArrayObject=[];
        weekDayStr='';
        delArea=[];
        delArray=[];
    }
</script>
</body>
</html>